#include "LabelCell.h"
#include "ui_LabelCell.h"
#include <QDebug>
#include <QStyle>

LabelCell::LabelCell(QWidget *parent) :
    CellBase(parent),
    ui(new Ui::LabelCell)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_StyledBackground);
}
LabelCell::~LabelCell()
{
    delete ui;
}

void LabelCell::updateData(const QVariant &data){
    CellBase::updateData(data);
    if(data.canConvert(QMetaType::QString)){
        ui->label_text->setText(data.toString());
    }
    else if(data.canConvert(QMetaType::QVariantMap)){
        ui->label_text->setText(data.toMap().value("text").toString());
    }
    else{

    }
}
void LabelCell::setData(const QVariant &data){
    CellBase::setData(data);
    if(data.canConvert(QMetaType::QString)){
        ui->label_text->setText(data.toString());
    }
    else if(data.canConvert(QMetaType::QVariantMap)){
        ui->label_text->setText(data.toMap().value("text").toString());
    }
    else{

    }
}
CellBase* LabelCell::ctor(QWidget *parent){
    return new LabelCell(parent);
}

void LabelCell::setActived(bool actived){
    CellBase::setActived(actived);
}
void LabelCell::polish(){
    style()->polish(this);
    style()->polish(ui->label_text);
}

